#include "qgravity.h"

#include "dna.h"

QGravity::QGravity ( QGame* parent, Dna* dna, int n, int width, int height ) : QLife ( parent, dna, n, width, height )
{
	x = rand() % getWidth();
	y = rand() % getHeight();
}

void QGravity::think()
{
	if ( energy < 150 )
	{
		energy = energy + ( energy / ( 10 * energy ) );
	}
}

void QGravity::collectData()
{
	QStringList data;

	data << "Type" << "Gravity";
	data << "Id" <<
	QString ( "%1" ).arg ( getId() );
	data << "" << "";
	data << "Energy" <<
	QString ( "%1" ).arg ( getEnergy(), 0, 'f', 1 );
	data << "" << "";
	data << "Is Alive" <<
	QString ( "%1" ).arg ( isAlive() );

	emit ( config ( getId(), data ) );
}

QString QGravity::getName()
{
	return name;
}

void QGravity::initDecay()
{}

void QGravity::decay()
{}

void QGravity::run()
{
	setPriority ( QThread::LowestPriority );
	exec();
}
